package com.lbh.cloudgallery.service.impl;

import com.lbh.cloudgallery.entity.AuthorEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxx.common.utils.PageUtils;
import com.xxx.common.utils.Query;

import com.lbh.cloudgallery.dao.AddressDao;
import com.lbh.cloudgallery.entity.AddressEntity;
import com.lbh.cloudgallery.service.AddressService;


@Service("addressService")
public class AddressServiceImpl extends ServiceImpl<AddressDao, AddressEntity> implements AddressService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<AddressEntity> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (!StringUtils.isEmpty(key)){
            wrapper.eq("id",key)
                    .or().like("receiver_name",key)
            ;
        }
        IPage<AddressEntity> page = this.page(
                new Query<AddressEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}